package com.smcaiot.jftorg.south.convert;

import com.smcaiot.jftorg.domain.user.User;
import com.smcaiot.jftorg.south.entity.JftUser;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @Author: cz
 * @Date: 2023/9/26
 * @Description:
 */
@Mapper
public interface JftUserConvert {

    JftUserConvert INSTANCE = Mappers.getMapper(JftUserConvert.class);

    @Mapping(target = "warningSignal", expression = "java(com.smcaiot.jftorg.domain.org.OrgId.from(user.getWarningSignal()))")
    User to(JftUser user);

    @Mapping(target = "warningSignal", expression = "java(user.getOrgId().value())")
    @Mapping(target = "role", expression = "java(user.getRole().getCode())")
    JftUser from(User user);

}
